<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<script tpe=text/javascript>
	var str="aaaabbcccccdeeeff";
	var obj={};
	for(var i=0;i<str.length;i++){
		 var v=str.charAt(i);
		 if(obj[v]&&obj[v].value==v){
			 	obj[v].count=++obj[v].count;
			 }else{
				obj[v]={};
				obj[v].count=1;
				obj[v].value=v;
			}
		}
		for(key in obj){
			 document.write(obj[key].value+"="+obj[key].count+"&nbsp;")/*大括号创建对象，用key键值对表示其中对象数组*/
			}
</script>
</body>
</html>
